package com.pkx.guide.info.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.guide.common.annotation.Log;
import com.pkx.guide.common.annotation.ORpose;
import com.pkx.guide.common.enums.BusinessType;
import com.pkx.guide.info.entity.TInfoGuidePublishTask;
import com.pkx.guide.info.service.TInfoGuidePublishTaskService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 诱导屏自动发布策略
 *
 * @Author : YangLe
 * @create 2025/10/31 10:02
 */
@RestController
@RequestMapping("/info/publishTask")
@Tag(name = "诱导屏自动发布策略")
@Slf4j
@ORpose
public class TInfoGuidePublishTaskController {
    @Resource
    private TInfoGuidePublishTaskService tInfoGuidePublishTaskService;

    @Operation(summary = "诱导屏自动发布策略分页列表")
    @GetMapping("/page")
    public IPage<TInfoGuidePublishTask> page(Page page, TInfoGuidePublishTask tInfoGuidePublishTask) {
        return tInfoGuidePublishTaskService.pageList(page, tInfoGuidePublishTask);
    }

    @Operation(summary = "诱导屏自动发布策略列表")
    @GetMapping("/list")
    public List<TInfoGuidePublishTask> list(TInfoGuidePublishTask tInfoGuidePublishTask) {
        return tInfoGuidePublishTaskService.listByEntity(tInfoGuidePublishTask);
    }

    @Operation(summary = "诱导屏自动发布策略详情")
    @GetMapping(value = "/{id}")
    public TInfoGuidePublishTask selectById(@PathVariable("id") Integer id) {
        return tInfoGuidePublishTaskService.selectById(id);
    }

    @Operation(summary = "诱导屏自动发布策略新增")
    @PostMapping("/")
    @Log(title = "诱导屏自动发布策略", businessType = BusinessType.INSERT)
    public Boolean add(@RequestBody TInfoGuidePublishTask tInfoGuidePublishTask) throws Exception {
        return tInfoGuidePublishTaskService.saveTInfoGuidePublish(tInfoGuidePublishTask);
    }
    @Operation(summary = "诱导屏自动发布策略删除(单个条目)")
    @DeleteMapping(value = "/{id}")
    @Log(title = "诱导屏自动发布策略", businessType = BusinessType.DELETE)
    public Boolean deleteById(@PathVariable("id") Integer id) {
        return tInfoGuidePublishTaskService.deleteById(id);
    }

}
